home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / ws_enc1a / ws_encry.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1999-10-09  |  10.5 KB  |  279 lines

  1. VERSION 5.00
  2. Begin VB.Form frmWs_Encrypt 
  3.    BackColor       =   &H00000000&
  4.    Caption         =   "WS_ENCRYPT"
  5.    ClientHeight    =   4995
  6.    ClientLeft      =   60
  7.    ClientTop       =   1455
  8.    ClientWidth     =   9480
  9.    Icon            =   "WS_Encrypt.frx":0000
  10.    LinkTopic       =   "Form1"
  11.    ScaleHeight     =   4995
  12.    ScaleWidth      =   9480
  13.    Begin VB.TextBox Text1 
  14.       BackColor       =   &H00000000&
  15.       BeginProperty Font 
  16.          Name            =   "System"
  17.          Size            =   9.75
  18.          Charset         =   0
  19.          Weight          =   700
  20.          Underline       =   0   'False
  21.          Italic          =   0   'False
  22.          Strikethrough   =   0   'False
  23.       EndProperty
  24.       ForeColor       =   &H0000FF00&
  25.       Height          =   360
  26.       Index           =   3
  27.       Left            =   315
  28.       TabIndex        =   7
  29.       Top             =   4275
  30.       Width           =   8655
  31.    End
  32.    Begin VB.TextBox Text1 
  33.       BackColor       =   &H00000000&
  34.       BeginProperty Font 
  35.          Name            =   "System"
  36.          Size            =   9.75
  37.          Charset         =   0
  38.          Weight          =   700
  39.          Underline       =   0   'False
  40.          Italic          =   0   'False
  41.          Strikethrough   =   0   'False
  42.       EndProperty
  43.       ForeColor       =   &H0000FF00&
  44.       Height          =   360
  45.       Index           =   1
  46.       Left            =   270
  47.       TabIndex        =   1
  48.       Top             =   2250
  49.       Width           =   8610
  50.    End
  51.    Begin VB.TextBox Text1 
  52.       BackColor       =   &H00000000&
  53.       BeginProperty Font 
  54.          Name            =   "System"
  55.          Size            =   9.75
  56.          Charset         =   0
  57.          Weight          =   700
  58.          Underline       =   0   'False
  59.          Italic          =   0   'False
  60.          Strikethrough   =   0   'False
  61.       EndProperty
  62.       ForeColor       =   &H0000FF00&
  63.       Height          =   330
  64.       Index           =   0
  65.       Left            =   225
  66.       TabIndex        =   0
  67.       Top             =   1260
  68.       Width           =   8610
  69.    End
  70.    Begin VB.TextBox Text1 
  71.       BackColor       =   &H00000000&
  72.       BeginProperty Font 
  73.          Name            =   "System"
  74.          Size            =   9.75
  75.          Charset         =   0
  76.          Weight          =   700
  77.          Underline       =   0   'False
  78.          Italic          =   0   'False
  79.          Strikethrough   =   0   'False
  80.       EndProperty
  81.       ForeColor       =   &H0000FF00&
  82.       Height          =   360
  83.       Index           =   2
  84.       Left            =   270
  85.       TabIndex        =   2
  86.       Top             =   3285
  87.       Width           =   8655
  88.    End
  89.    Begin VB.Label Label1 
  90.       BackColor       =   &H00000000&
  91.       Caption         =   "Error Messages"
  92.       BeginProperty Font 
  93.          Name            =   "System"
  94.          Size            =   9.75
  95.          Charset         =   0
  96.          Weight          =   700
  97.          Underline       =   0   'False
  98.          Italic          =   0   'False
  99.          Strikethrough   =   0   'False
  100.       EndProperty
  101.       ForeColor       =   &H0000FF00&
  102.       Height          =   285
  103.       Index           =   4
  104.       Left            =   315
  105.       TabIndex        =   8
  106.       Top             =   3960
  107.       Width           =   1590
  108.    End
  109.    Begin VB.Label Label1 
  110.       BackColor       =   &H00000000&
  111.       Caption         =   "Cypher Text from above line becomes decrypted."
  112.       BeginProperty Font 
  113.          Name            =   "System"
  114.          Size            =   9.75
  115.          Charset         =   0
  116.          Weight          =   700
  117.          Underline       =   0   'False
  118.          Italic          =   0   'False
  119.          Strikethrough   =   0   'False
  120.       EndProperty
  121.       ForeColor       =   &H0000FF00&
  122.       Height          =   285
  123.       Index           =   3
  124.       Left            =   900
  125.       TabIndex        =   6
  126.       Top             =   3015
  127.       Width           =   4830
  128.    End
  129.    Begin VB.Label Label1 
  130.       BackColor       =   &H00000000&
  131.       Caption         =   "Password becomes encrypted. You may also enter a previously encrypted password here."
  132.       BeginProperty Font 
  133.          Name            =   "System"
  134.          Size            =   9.75
  135.          Charset         =   0
  136.          Weight          =   700
  137.          Underline       =   0   'False
  138.          Italic          =   0   'False
  139.          Strikethrough   =   0   'False
  140.       EndProperty
  141.       ForeColor       =   &H0000FF00&
  142.       Height          =   465
  143.       Index           =   2
  144.       Left            =   900
  145.       TabIndex        =   5
  146.       Top             =   1800
  147.       Width           =   8700
  148.    End
  149.    Begin VB.Line Line1 
  150.       BorderColor     =   &H0000FF00&
  151.       BorderWidth     =   2
  152.       Index           =   5
  153.       X1              =   630
  154.       X2              =   765
  155.       Y1              =   3240
  156.       Y2              =   3060
  157.    End
  158.    Begin VB.Line Line1 
  159.       BorderColor     =   &H0000FF00&
  160.       BorderWidth     =   2
  161.       Index           =   4
  162.       X1              =   495
  163.       X2              =   630
  164.       Y1              =   3060
  165.       Y2              =   3240
  166.    End
  167.    Begin VB.Line Line1 
  168.       BorderColor     =   &H0000FF00&
  169.       BorderWidth     =   2
  170.       Index           =   3
  171.       X1              =   630
  172.       X2              =   630
  173.       Y1              =   2790
  174.       Y2              =   3195
  175.    End
  176.    Begin VB.Line Line1 
  177.       BorderColor     =   &H0000FF00&
  178.       BorderWidth     =   2
  179.       Index           =   2
  180.       X1              =   630
  181.       X2              =   765
  182.       Y1              =   2160
  183.       Y2              =   1980
  184.    End
  185.    Begin VB.Line Line1 
  186.       BorderColor     =   &H0000FF00&
  187.       BorderWidth     =   2
  188.       Index           =   1
  189.       X1              =   495
  190.       X2              =   630
  191.       Y1              =   1980
  192.       Y2              =   2160
  193.    End
  194.    Begin VB.Line Line1 
  195.       BorderColor     =   &H0000FF00&
  196.       BorderWidth     =   2
  197.       Index           =   0
  198.       X1              =   630
  199.       X2              =   630
  200.       Y1              =   1710
  201.       Y2              =   2115
  202.    End
  203.    Begin VB.Label Label1 
  204.       BackColor       =   &H00000000&
  205.       Caption         =   "Enter Password Here"
  206.       BeginProperty Font 
  207.          Name            =   "System"
  208.          Size            =   9.75
  209.          Charset         =   0
  210.          Weight          =   700
  211.          Underline       =   0   'False
  212.          Italic          =   0   'False
  213.          Strikethrough   =   0   'False
  214.       EndProperty
  215.       ForeColor       =   &H0000FF00&
  216.       Height          =   285
  217.       Index           =   1
  218.       Left            =   270
  219.       TabIndex        =   4
  220.       Top             =   945
  221.       Width           =   2130
  222.    End
  223.    Begin VB.Label Label1 
  224.       BackColor       =   &H00000000&
  225.       Caption         =   "WS_Encrypt"
  226.       BeginProperty Font 
  227.          Name            =   "System"
  228.          Size            =   19.5
  229.          Charset         =   0
  230.          Weight          =   700
  231.          Underline       =   0   'False
  232.          Italic          =   0   'False
  233.          Strikethrough   =   0   'False
  234.       EndProperty
  235.       ForeColor       =   &H0000FF00&
  236.       Height          =   510
  237.       Index           =   0
  238.       Left            =   270
  239.       TabIndex        =   3
  240.       Top             =   90
  241.       Width           =   6585
  242.    End
  243. Attribute VB_Name = "frmWs_Encrypt"
  244. Attribute VB_GlobalNameSpace = False
  245. Attribute VB_Creatable = False
  246. Attribute VB_PredeclaredId = True
  247. Attribute VB_Exposed = False
  248. Private Sub Text1_Change(Index As Integer)
  249. 'This program is based on a javascript program found at "www.hispasec.com/wsftp.asp". Kudos to its author.
  250. 'Ws_FTP has a feature that lets you save the password you use to connect to FTP sites. It saves the
  251. 'password as an encrypted string in the WS_FTP.ini file. This program can encrypt and decrypted strings
  252. 'using the same algorithm that WS_FTP uses. This form serves as a demonstration of the encrypt and decrypt function
  253. 'which can be found in modCrypt. modMath has a function that turns Hex strings into integers. I couldn't find
  254. 'a function like that in VB.
  255. 'This program uses simple crypto algorithms which makes it a good introduciton to encryption techniques
  256. 'that are actually being used in commercial programs. If your interested in learning how it works I'll
  257. 'get you started by explaining the format of the cyphertext. You can figure out the algorithms by studying
  258. 'modCrypt.WS_Decrypt and modCrypt.WS_Encrypt which is quite simple. If you not interested in learning how
  259. 'it works you can use
  260. 'the functions pretty much as they are. The only thing you should change is the way they handle error detection.
  261. 'Here is the cyphertext format:
  262. 'PWD=V953A989B6236B3231E395029D36810D1A19B9668
  263. 'This string was generated by WS_FTP and decrypts to "head". The "PWD=" is part of the ini file format and
  264. 'can not be used in "modCrypt.WS_Decrypt". WS_FTP always generates a "V" as the next character and it has no impact
  265. 'on decryption. For each letter in the plaintext there is a salt value in hex (one didgit); in this case "953A".
  266. 'Salt values are usually merely randomly generated numbers that make it possible for a plaintext to be encrypted
  267. 'into a different ciphertext each time it is encrypted. WS_FTP seems to somehow base its salt values on the plaintext
  268. 'which means for each time you encrypt a password in WS_FTP you get the same cyphertext. My program uses randomization for its salts. Moving on, everything past the first
  269. '32 characters of the ciphertext (A19B9668) is the actual encrypted password in hex after it been encrypted with its
  270. 'corrosponding salt value. The specific of this are better understood by studying the sourcecode. Everything past the salt(953A)
  271. 'and before the encrypted password (A19B9668) are placeholders. WS_FTP places hex numbers here, I suppose, to intimidate the
  272. 'cryptanalist. My program puts "X"'s there. You might have noticed that the format only allows for passwords =< then 32 characters.
  273. 'Sometimes the encryption function will accept an extended ascii by accident but was not intended for such. You should
  274. 'write code that detects both of these possibilities before using it in a program.
  275. If Index = 0 Then Text1(1) = modCrypt.WS_Encrypt(Text1(0))
  276. If Index = 1 Then Text1(2) = modCrypt.WS_Decrypt(Text1(1))
  277.                             
  278. End Sub
  279.